<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::domain(env('ROUTE_DOMAIN'))->group(function () {

	Route::get('login', 'LoginController@index')->name('login');
	Route::post('login', 'LoginController@login');
	Route::get('download', 'DefaultController@download')->name('download');

	/* 登录中间件 */
	Route::middleware('auth:admin')->group(function () {

		/*公共路由*/
		Route::get('/users', 'Mgt\UtilController@users')->name('util.users');

		// 后台首页
		Route::get('/', 'DefaultController@index')->name('index');
		// 退出登录
		Route::get('logout', 'DefaultController@logout')->name('logout');

		/* 权限中间件 */
		Route::middleware('permission:admin')->group(function () {

			/* 系统设置 */
			Route::prefix('system')->name('system.')->group(function () {
				Route::resource('role', 'Acl\RoleController');

				Route::prefix('permission')->name('permission.')->group(function () {
					Route::get('index', 'Acl\PermissionController@index')->name('index');
					Route::get('create', 'Acl\PermissionController@create')->name('create');
					Route::post('store', 'Acl\PermissionController@store')->name('store');
					Route::get('edit/{id}', 'Acl\PermissionController@edit')->name('edit');
					Route::put('update/{id}', 'Acl\PermissionController@update')->name('update');
					Route::get('show/{id}', 'Acl\PermissionController@show')->name('show');
					Route::get('list', 'Acl\PermissionController@list')->name('list');
				});

				Route::resource('staff', 'Acl\StaffController');
				Route::get('passwd', 'Acl\StaffController@passwd')->name('staff.passwd');
				Route::put('passwd/{id}', 'Acl\StaffController@chgpwd')->name('staff.chgpwd');
				Route::resource('branch', 'Mgt\BranchController');
				Route::resource('enum', 'Mgt\EnumController');
				Route::get('getEnumeration', 'Mgt\EnumController@getEnumeration')->name('getEnumeration');

				Route::get('debug', 'Mgt\SysController@debug')->name('debug.index');
				Route::post('{id}/debug', 'Mgt\SysController@update')->name('debug.update');
			});


			/* 用户 */
			Route::prefix('user')->name('user.')->group(function () {

				Route::get('index', 'Mgt\UserController@index')->name('index');
				Route::get('create', 'Mgt\UserController@create')->name('create');
				Route::post('store', 'Mgt\UserController@store')->name('store');
				Route::get('edit/{uid}', 'Mgt\UserController@edit')->name('edit');
				Route::put('update/{uid}', 'Mgt\UserController@update')->name('update');
				Route::get('view/{uid}', 'Mgt\UserController@view')->name('view');

				Route::get('print/{uid}', 'Mgt\UserController@print')->name('print');
			});

			/* 成长银行 */
			Route::prefix('bank')->name('bank.')->group(function () {
				Route::get('sign', 'Biz\BankController@sign')->name('sign');
				Route::get('show', 'Biz\BankController@show')->name('show');
				//签到和奖励
				Route::post('checkin', 'Biz\BankController@checkin')->name('checkin');
				//借书和还书
				Route::post('borrow', 'Biz\BankController@borrow')->name('borrow');
				Route::post('return', 'Biz\BankController@return')->name('return');

				Route::get('apply', 'Biz\BankController@apply')->name('apply');
			});

			/* 志愿者 */
			Route::prefix('volunteer')->name('volunteer.')->group(function () {
				Route::get('index', 'Mgt\VolunteerController@index')->name('index');
				Route::get('create', 'Mgt\VolunteerController@create')->name('create');
				Route::post('store', 'Mgt\VolunteerController@store')->name('store');
				Route::get('edit/{uid}', 'Mgt\VolunteerController@edit')->name('edit');
				Route::put('update/{uid}', 'Mgt\VolunteerController@update')->name('update');
				Route::get('view/{uid}', 'Mgt\VolunteerController@view')->name('view');

				Route::get('statistics', 'Mgt\VolunteerController@statistics')->name('statistics');
			});

			/* 活动 */
			Route::prefix('activity')->name('activity.')->group(function () {

				Route::get('index', 'Mgt\ActivityController@index')->name('index');

				Route::get('create', 'Mgt\ActivityController@create')->name('create');
				Route::post('store', 'Mgt\ActivityController@store')->name('store');

				Route::get('show/{aid}/{action}', 'Mgt\ActivityController@show')->name('show');
				Route::get('book/{aid}/{action}', 'Mgt\ActivityController@book')->name('book');
				Route::post('status/{aid}', 'Mgt\ActivityController@status')->name('status');

				Route::get('edit/{aid}', 'Mgt\ActivityController@edit')->name('edit');
				Route::put('update/{aid}', 'Mgt\ActivityController@update')->name('update');

				Route::get('acts/{aid}', 'Mgt\ActivityController@acts')->name('acts');
				Route::get('joins/{aid}', 'Mgt\ActivityController@joins')->name('joins');
				Route::get('borrows/{aid}', 'Mgt\ActivityController@borrows')->name('borrows');
				Route::get('returns/{aid}', 'Mgt\ActivityController@returns')->name('returns');
			});

			/* 书库 */
			Route::prefix('book')->name('book.')->group(function () {

				Route::get('index', 'Mgt\BookController@index')->name('index');
				Route::get('create', 'Mgt\BookController@create')->name('create');
				Route::post('store', 'Mgt\BookController@store')->name('store');
				Route::get('edit/{id}', 'Mgt\BookController@edit')->name('edit');
				Route::put('update/{id}', 'Mgt\BookController@update')->name('update');
				Route::get('show/{id}', 'Mgt\BookController@show')->name('show');

				//单本书籍的借阅记录
				Route::get('borrows/{id}', 'Mgt\BookController@borrows')->name('borrows');

				Route::get('bookstore', 'Mgt\BookController@bookstore')->name('bookstore');
			});

			/* 培训 */
			Route::prefix('train')->name('train.')->group(function () {
				Route::get('index', 'Edu\TrainController@index')->name('index');
				Route::get('create', 'Edu\TrainController@create')->name('create');
				Route::post('store', 'Edu\TrainController@store')->name('store');
				Route::get('{id}/edit', 'Edu\TrainController@edit')->name('edit');
				Route::put('{id}/update', 'Edu\TrainController@update')->name('update');
				Route::get('users/{id}', 'Edu\TrainController@users')->name('users');
				Route::get('attachment/{id}', 'Edu\TrainController@attachment')->name('attachment');
				Route::get('{id}/add', 'Edu\TrainController@add')->name('add');
				Route::post('addUser', 'Edu\TrainController@addUser')->name('addUser');
				Route::get('{id}/export', 'Edu\TrainController@export')->name('export');

				Route::post('status', 'Edu\TrainController@status')->name('status');


				Route::get('category/{id}', 'Edu\TrainController@category')->name('category.index');
				Route::get('category/{id}/create', 'Edu\TrainController@categoryCreate')->name('category.create');
				Route::post('category/{id}/store', 'Edu\TrainController@categoryStore')->name('category.store');
				Route::get('category/{id}/edit', 'Edu\TrainController@categoryEdit')->name('category.edit');
				Route::put('category/{id}/update', 'Edu\TrainController@categoryUpdate')->name('category.update');


				Route::get('clase', 'Edu\TrainController@clase')->name('clase.index');
				Route::get('clase/{id}/create', 'Edu\TrainController@claseCreate')->name('clase.create');
				Route::post('clase/{id}/store', 'Edu\TrainController@claseStore')->name('clase.store');
				Route::get('clase/{id}/edit', 'Edu\TrainController@claseEdit')->name('clase.edit');
				Route::put('clase/{id}/update', 'Edu\TrainController@claseUpdate')->name('clase.update');

				Route::get('deploy', 'Edu\TrainController@deploy')->name('deploy.index');
				Route::get('deploy/create', 'Edu\TrainController@deployCreate')->name('deploy.create');
				Route::post('deploy/store', 'Edu\TrainController@deployStore')->name('deploy.store');
				Route::get('deploy/{id}/edit', 'Edu\TrainController@deployEdit')->name('deploy.edit');
				Route::put('deploy/{id}/update', 'Edu\TrainController@deployUpdate')->name('deploy.update');
				Route::post('deploy/change', 'Edu\TrainController@deployChange')->name('deploy.change');
			});

			/* 花名册 */
			Route::prefix('student')->name('student.')->group(function () {
				Route::get('index', 'Lst\StudentController@index')->name('index');
				Route::get('create', 'Lst\StudentController@create')->name('create');
				Route::post('store', 'Lst\StudentController@store')->name('store');

				Route::get('publish', 'Lst\StudentController@publish')->name('publish.index');
				Route::get('publish/create', 'Lst\StudentController@publishCreate')->name('publish.create');
				Route::post('publish/store', 'Lst\StudentController@publishStore')->name('publish.store');
				Route::get('publish/{id}/edit', 'Lst\StudentController@publishEdit')->name('publish.edit');
				Route::put('publish/{id}/update', 'Lst\StudentController@publishUpdate')->name('publish.update');
				Route::post('publish/change', 'Lst\StudentController@publishChange')->name('publish.change');

				Route::get('publish/{pid}/{cid}/shows', 'Lst\StudentController@shows')->name('publish.shows');
				Route::get('publish/{pid}/{cid}/export', 'Lst\StudentController@export')->name('publish.export');
			});


			Route::prefix('borrow')->name('borrow.')->group(function () {
				Route::get('index', 'Biz\BorrowController@index')->name('index');
			});

			/* 积分 */
			Route::prefix('point')->name('point.')->group(function () {
				Route::resource('gift', 'Biz\PointController');
				Route::get('list', 'Biz\PointController@list')->name('gift.list');
				Route::post('exchange', 'Biz\PointController@exchange')->name('gift.exchange');
			});

			/* 答题活动 */
			Route::prefix('exam')->name('exam.')->group(function () {
				Route::get('index', 'Exm\WarehouseController@index')->name('index');
				Route::get('create', 'Exm\WarehouseController@create')->name('create');
				Route::post('store', 'Exm\WarehouseController@store')->name('store');
				Route::get('edit/{id}', 'Exm\WarehouseController@edit')->name('edit');
				Route::put('update/{id}', 'Exm\WarehouseController@update')->name('update');
				Route::get('show/{id}', 'Exm\WarehouseController@show')->name('show');

				Route::get('item/{id}', 'Exm\WarehouseController@item')->name('item');
				Route::post('item/{id}', 'Exm\WarehouseController@select')->name('select');

				Route::get('recruit', 'Exm\WarehouseController@recruit')->name('recruit');
			});

			/* 答题题库 */
			Route::prefix('question')->name('question.')->group(function () {
				Route::get('subject', 'Exm\QuestionController@subject')->name('subject');
				Route::get('index', 'Exm\QuestionController@index')->name('index');
				Route::get('create', 'Exm\QuestionController@create')->name('create');
				Route::post('store', 'Exm\QuestionController@store')->name('store');
				Route::get('edit/{id}', 'Exm\QuestionController@edit')->name('edit');
				Route::put('update/{id}', 'Exm\QuestionController@update')->name('update');
				Route::get('show/{id}', 'Exm\QuestionController@show')->name('show');
			});

			/* 专题活动 */
			Route::prefix('act')->name('act.')->group(function () {
				Route::get('index', 'Act\TopicController@index')->name('index');
				Route::get('create', 'Act\TopicController@create')->name('create');
				Route::post('store', 'Act\TopicController@store')->name('store');
				Route::get('edit/{id}', 'Act\TopicController@edit')->name('edit');
				Route::post('update/{id}', 'Act\TopicController@update')->name('update');
				Route::get('show/{id}', 'Act\TopicController@show')->name('show');
				Route::get('view/{id}', 'Act\TopicController@view')->name('view');
				Route::get('list', 'Act\TopicController@lists')->name('lists');
				/*Route::get('topic/{id}/question', 'Act\TopicController@question')->name('question');
				Route::post('topic/{id}/question', 'Act\TopicController@question');
*/
				Route::prefix('question')->name('question.')->group(function () {
					Route::get('{tid}/index', 'Act\QuestionController@index')->name('index');
					Route::get('{tid}/create/select', 'Act\QuestionController@createSelect')->name('createSelect');
					Route::get('{tid}/create/blank', 'Act\QuestionController@createBlank')->name('createBlank');
					Route::post('{tid}/store', 'Act\QuestionController@store')->name('store');
					Route::get('{tid}/edit/{qid}/select', 'Act\QuestionController@editSelect')->name('editSelect');
					Route::get('{tid}/edit/{qid}/blank', 'Act\QuestionController@editBlank')->name('editBlank');
					Route::post('{tid}/update/{qid}', 'Act\QuestionController@update')->name('update');
					Route::get('{tid}/show/{qid}', 'Act\QuestionController@show')->name('show');					
				});
			});
		});
	});

	/* 公共路由 */
	Route::get('/captcha', 'Mgt\UtilController@captcha')->name('util.captcha');
	Route::get('/safecode', 'Mgt\UtilController@safecode')->name('util.safecode');
	Route::get('/schools', 'Mgt\UtilController@schools')->name('util.schools');
	Route::get('/users', 'Mgt\UtilController@users')->name('util.users');
});
